This page was generated from notebook Models/Basic_France_model/Planing_optimisation/case_planing_step_by_step_learning.ipynb with nbconvert
If you're lost, you can go back to
This document contains a description of optimisation tools for electric system planing simulation with only one node. Having one node is a strong approximation but it is usefull to learn how the tool works.
If you don't known anything about these optimisatino problem, you might prefer to start with operation optimisation in file optim-Operation.ipynb, you can have a look at the whole notebook's results through the web page here. In files BasicFunctionalities/input-XXX.ipynb you can learn to understand input data (consumption, availability).
(Text below is almost the same as for operation)
This document will gives a chance to understand
It proposes to enter the subject by increasing progressively the number of variables and constraints in the optimisation problem, hence moving toward more realism through the document, introducing:
It relies on different test cases that allow to
If, after reading this file, you want to build your own pyomo model you can start by having a look at GetElectricSystemModel_PlaningSingleNode function in f_planingModels.py
#region importation of modules
import os
import sys
if os.path.basename(os.getcwd())=='Planing_optimisation':
sys.path.append('../../../')
import sys
if sys.platform != 'win32':
myhost = os.uname()[1]
else : myhost = ""
if (myhost=="jupyter-sop"):
## for https://jupyter-sop.mines-paristech.fr/ users, you need to
# (1) run the following in a terminal
if (os.system("/opt/mosek/9.2/tools/platform/linux64x86/bin/lmgrd -c /opt/mosek/9.2/tools/platform/linux64x86/bin/mosek.lic -l lmgrd.log")==0):
os.system("/opt/mosek/9.2/tools/platform/linux64x86/bin/lmutil lmstat -c 27007@127.0.0.1 -a")
# (2) definition of license
os.environ["MOSEKLM_LICENSE_FILE"] = '@jupyter-sop'
import numpy as np
import pandas as pd
import csv
#import docplex
import datetime
import copy
import plotly.graph_objects as go
import matplotlib.pyplot as plt
from sklearn import linear_model
import sys
from functions.f_graphicalTools import *
from functions.f_consumptionModels import *
from Models.Basic_France_models.Planing_optimisation.f_planingModels import *
# Change this if you have other solvers obtained here
## https://ampl.com/products/solvers/open-source/
## for eduction this site provides also several professional solvers, that are more efficient than e.g. cbc
#endregion
#region Solver and data location definition
InputConsumptionFolder='../Consumption/Data/'
InputProductionFolder='../Production/Data/'
InputPlaningFolder='Data/'
GraphicalResultsFolder="GraphicalResults/"
InputFolder='Data/input/'
solver= 'mosek' ## no need for solverpath with mosek.
BaseSolverPath='/Users/robin.girard/Documents/Code/Packages/solvers/ampl_macosx64'
sys.path.append(BaseSolverPath)
solvers= ['gurobi','knitro','cbc'] # 'glpk' is too slow 'cplex' and 'xpress' do not work
solverpath= {}
for solver in solvers : solverpath[solver]=BaseSolverPath+'/'+solver
cplexPATH='/Applications/CPLEX_Studio1210/cplex/bin/x86-64_osx'
sys.path.append(cplexPATH)
solverpath['cplex']=cplexPATH+"/"+"cplex"
solver = 'mosek'
#endregion
Before you start with the math, you should
#region I - Simple single area : loading parameters
year=2013
#### reading areaConsumption availabilityFactor and TechParameters CSV files
areaConsumption = pd.read_csv(InputConsumptionFolder+'areaConsumption'+str(year)+'_FR.csv',sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date"])
availabilityFactor = pd.read_csv(InputProductionFolder+'availabilityFactor'+str(year)+'_FR.csv',sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date","TECHNOLOGIES"])
TechParameters = pd.read_csv(InputPlaningFolder+'Planing-Simple_TECHNOLOGIES.csv',sep=',',decimal='.',skiprows=0,comment="#").set_index(["TECHNOLOGIES"])
TechParameters.head()
#### Selection of subset
Selected_TECHNOLOGIES=['OldNuke','CCG'] #you can add technologies here
availabilityFactor=availabilityFactor.loc[(slice(None),Selected_TECHNOLOGIES),:]
TechParameters=TechParameters.loc[Selected_TECHNOLOGIES,:]
#TechParameters.loc[TechParameters.TECHNOLOGIES=="OldNuke",'maxCapacity']=63000 ## Limit to actual installed capacity
#endregion
/var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/463447673.py:10: FutureWarning: The behavior of indexing on a MultiIndex with a nested sequence of labels is deprecated and will change in a future version. `series.loc[label, sequence]` will raise if any members of 'sequence' or not present in the index's second level. To retain the old behavior, use `series.index.isin(sequence, level=1)` availabilityFactor=availabilityFactor.loc[(slice(None),Selected_TECHNOLOGIES),:]
#region I - Simple single area : Solving and loading results
model = GetElectricSystemModel_PlaningSingleNode(Parameters={"areaConsumption" : areaConsumption,
"availabilityFactor" : availabilityFactor,
"TechParameters" : TechParameters})
if solver in solverpath : opt = SolverFactory(solver,executable=solverpath[solver])
else : opt = SolverFactory(solver)
results=opt.solve(model)
## result analysis
Variables=getVariables_panda_indexed(model)
print(extractCosts(Variables))
print(extractEnergyCapacity(Variables))
#pour avoir la production en KWh de chaque moyen de prod chaque heure
production_df=Variables['energy'].pivot(index="Date",columns='TECHNOLOGIES', values='energy')
### Check sum Prod = Consumption
Delta=(production_df.sum(axis=1) - areaConsumption.areaConsumption);
abs(Delta).max()
#endregion
Capacity_Milliards_euros Energy_Milliards_euros
TECHNOLOGIES
OldNuke 13.894902 3.444102
CCG 1.262412 -0.000000
Capacity_GW Production_TWh
TECHNOLOGIES
OldNuke 56.7 492.01462
CCG 10.8 0.00000
0.0
Verify that the sum of market prices allows all actors to cover fixed and marginal cost. do they earn more ? why ?
#region I - Simple single area : visualisation and lagrange multipliers
### representation des résultats
fig=MyStackedPlotly(y_df=production_df,Conso = areaConsumption)
fig=fig.update_layout(title_text="Production électrique (en KWh)", xaxis_title="heures de l'année")
#plotly.offline.plot(fig, filename=GraphicalResultsFolder+'file.html') ## offline
fig.show()
#### lagrange multipliers
Constraints= getConstraintsDual_panda(model)
# Analyse energyCtr
energyCtrDual=Constraints['energyCtr']; energyCtrDual['energyCtr']=energyCtrDual['energyCtr']
energyCtrDual
round(energyCtrDual.energyCtr,2).unique()
# Analyse CapacityCtr
#CapacityCtrDual=Constraints['CapacityCtr'].pivot(index="Date",columns='TECHNOLOGIES', values='CapacityCtr')*1000000;
#round(CapacityCtrDual,2)
#round(CapacityCtrDual.OldNuke,2).unique() ## if you increase by Delta the installed capacity of nuke you decrease by xxx the cost when nuke is not sufficient
#round(CapacityCtrDual.CCG,2).unique() ## increasing the capacity of CCG as no effect on prices
#endregion
array([7.])
In the this section, we will increase the complexity of the problem given in Section 2 and add : dependency on area z (country),a congestion constraint, ramp constraints.
\begin{align} &\text{Cost function }& &\min_{x} \sum_z \left ( \beta_{iz}\bar{x_{iz}} + \sum_t \sum_i \pi_{iz} x_{itz} \right ) \;\;\; & & \pi_{iz} \text{ marginal cost}\\ &\text{Power limit } & &\text{ s.t.} \;\; 0 \leq x_{itz}\leq a_{itz} \bar{x_{iz}} & &\bar{x_{iz}} \text{ installed power, } a_{itz} \text{ availability}\\ &\text{Meet demand } & & \sum_i x_{itz} \geq C_{tz} && C_{tz} \text{ Consumption}\\ &\text{Stock limit } & &\sum_t x_{it}\leq E_i && E_i=\bar{x_i}*N_i \text{ Energy capacity limit}\\ &\text{ramp limit } & &rc^-_i *x_{it}\leq x_{it}-x_{i(t+1)}\leq rc^+_i *x_{it} && rc^+_i rc^-_i\text{ ramp limit}\\ \end{align}#region II - Ramp Single area : loading parameters loading parameterscase with ramp constraints
year=2013
Selected_TECHNOLOGIES=['OldNuke', 'CCG',"curtailment"] #you'll add 'Solar' after
#### reading CSV files
areaConsumption = pd.read_csv(InputConsumptionFolder+'areaConsumption'+str(year)+'_FR.csv',
sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date"])
availabilityFactor = pd.read_csv(InputProductionFolder+'availabilityFactor'+str(year)+'_FR.csv',
sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date","TECHNOLOGIES"])
TechParameters = pd.read_csv(InputPlaningFolder+'Planing-RAMP1BIS_TECHNOLOGIES.csv',sep=',',decimal='.',skiprows=0,comment="#").set_index(["TECHNOLOGIES"])
#### Selection of subset
availabilityFactor=availabilityFactor.loc[(slice(None),Selected_TECHNOLOGIES),:]
TechParameters=TechParameters.loc[Selected_TECHNOLOGIES,:]
TechParameters.loc["OldNuke",'RampConstraintMoins']=0.01 ## a bit strong to put in light the effect
TechParameters.loc["OldNuke",'RampConstraintPlus']=0.02 ## a bit strong to put in light the effect
#endregion
/var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/253438452.py:12: FutureWarning: The behavior of indexing on a MultiIndex with a nested sequence of labels is deprecated and will change in a future version. `series.loc[label, sequence]` will raise if any members of 'sequence' or not present in the index's second level. To retain the old behavior, use `series.index.isin(sequence, level=1)`
#region II - Ramp Single area : solving and loading results
model = GetElectricSystemModel_PlaningSingleNode(Parameters={"areaConsumption" : areaConsumption,
"availabilityFactor" : availabilityFactor,
"TechParameters" : TechParameters})
opt = SolverFactory(solver)
results=opt.solve(model)
Variables=getVariables_panda_indexed(model)
print(extractCosts(Variables))
print(extractEnergyCapacity(Variables))
#pour avoir la production en KWh de chaque moyen de prod chaque heure
production_df=Variables['energy'].pivot(index="Date",columns='TECHNOLOGIES', values='energy')
### Check sum Prod = Consumption
Delta=(production_df.sum(axis=1) - areaConsumption.areaConsumption);
abs(Delta).max()
#endregion
Capacity_Milliards_euros Energy_Milliards_euros
TECHNOLOGIES
CCG 1.40268 2.709080
OldNuke 9.80240 3.007976
curtailment 0.00000 687.829674
Capacity_GW Production_TWh
TECHNOLOGIES
CCG 12.0 39.376163
OldNuke 40.0 429.710802
curtailment 9.0 22.927656
1.4551915228366852e-11
#region II - Ramp Single area : visualisation and lagrange multipliers
fig=MyStackedPlotly(y_df=production_df,Conso = areaConsumption)
fig=fig.update_layout(title_text="Production électrique (en KWh)", xaxis_title="heures de l'année")
#plotly.offline.plot(fig, filename=GraphicalResultsFolder+'file.html') ## offline
fig.show()
#### lagrange multipliers
Constraints= getConstraintsDual_panda(model)
# Analyse energyCtr
energyCtrDual=Constraints['energyCtr']; energyCtrDual['energyCtr']=energyCtrDual['energyCtr']*1000000
energyCtrDual
round(energyCtrDual.energyCtr,2).unique()
# Analyse CapacityCtr
#CapacityCtrDual=Constraints['maxCapacityCtr'].pivot(index="Date",columns='TECHNOLOGIES', values='CapacityCtr')*1000000;
#round(CapacityCtrDual,2)
#round(CapacityCtrDual.OldNuke,2).unique() ## if you increase by Delta the installed capacity of nuke you decrease by xxx the cost when nuke is not sufficient
#round(CapacityCtrDual.CCG,2).unique() ## increasing the capacity of CCG as no effect on prices
#endregion
array([-5.806320e+10, 3.000000e+10, 2.691000e+10, 6.880000e+07,
-2.998600e+10, -5.997900e+10, -4.998800e+09, 7.000000e+06,
-1.033360e+10, -2.788480e+10, -2.986240e+10, -4.937000e+09,
-1.120546e+11, 2.511780e+10, -5.701260e+10, -1.196560e+11,
-1.502052e+11, -5.492000e+08, 2.462340e+10, -1.495872e+11,
-2.559820e+10, 3.715000e+09, -2.370324e+11, -8.892200e+09,
-2.961520e+10, -2.835800e+09, -2.881180e+10, -2.094496e+11,
2.542680e+10, -6.170940e+10, 9.462400e+09, -2.701960e+10,
-2.393808e+11, -2.992432e+11, 1.566240e+10, -2.798840e+10,
-3.752560e+10, -8.204160e+10, -2.936800e+10, -3.291744e+11,
-3.023320e+10, -3.060400e+10, -6.587000e+10, -5.979360e+10,
-3.515600e+09, -5.960820e+10, -8.830400e+09, -2.677240e+10,
-5.472600e+10, -2.640160e+10, -3.159280e+10, -2.578360e+10,
-2.973880e+10, -3.002938e+11, -1.539132e+11, -2.702390e+11,
-5.725980e+10, -7.470800e+09, -2.967700e+10, -2.287900e+10,
-1.779734e+11, -2.207560e+10, -1.651360e+10, 2.542000e+08,
-8.966300e+10, -4.520880e+10, -5.812500e+10, -1.863782e+11,
-5.831040e+10, -9.572000e+09, -1.499580e+11, -7.965200e+09,
2.604480e+10, -2.732860e+10, -2.959400e+09, -8.972480e+10,
-3.239620e+10, -1.538120e+10, 3.776800e+09, -1.795184e+11,
-2.813200e+10, -4.566200e+09, 1.385020e+10, -2.001620e+10,
2.579760e+10, -2.675240e+10, 2.355400e+09, -2.693120e+11,
-2.699300e+11, 2.573580e+10, -3.587700e+10, -2.942980e+10,
-1.847000e+09, -8.850400e+09, -5.404620e+10, -2.139580e+10,
-8.935400e+10, -1.503288e+11, -1.790240e+11, -1.976900e+10,
1.490200e+09, -5.973180e+10, -3.165460e+10, 2.305840e+10,
1.551880e+10, -3.036310e+11, -3.462100e+10, -6.016440e+10,
-7.524360e+10, 2.833140e+10, -9.609020e+10, 8.102800e+09,
-2.094200e+09, -5.122400e+09, -8.997200e+10, -6.214200e+10,
-2.119040e+10, -3.554800e+10, -3.414660e+10, 1.737400e+09,
-2.875000e+10, -4.323120e+10, -3.626282e+11, -2.566000e+10,
1.922800e+09, -2.719276e+11, -2.862640e+10, -3.266340e+10,
-1.515030e+11, -8.620220e+10, -5.707440e+10, -2.402000e+08,
-1.494018e+11, -6.337800e+10, -2.535100e+10, -1.199650e+11,
-1.563852e+11, -2.101912e+11, 2.839320e+10, -5.849580e+10,
-2.514560e+10, -2.965700e+10, -3.017140e+10, -4.319000e+09,
-1.601550e+11, -2.717222e+11, -3.146920e+10, -6.424320e+10,
2.555040e+10, -1.820522e+11, -3.010960e+10, 2.293600e+09,
-3.468280e+10, -3.150840e+11, -3.109840e+10, -4.256000e+08,
-1.080800e+10, -7.866260e+10, -9.164060e+10, -3.177820e+10,
-2.893540e+10, -1.247660e+10, -2.436220e+10, 2.703360e+10,
-5.509680e+10, -8.686200e+10, -3.443560e+10, -6.543800e+09,
-3.029500e+10, -6.782760e+10, -2.294080e+10, 2.746620e+10,
-8.756180e+10, -4.092460e+10, -5.682720e+10, -4.498880e+11,
-1.848950e+11, -3.015298e+11, 1.706380e+10, 1.100740e+10,
-1.195942e+11, -2.213740e+10, -5.480000e+07, -1.576212e+11,
-2.399370e+11, -1.188526e+11, 2.596300e+10, 2.851680e+10,
-2.479480e+10, -2.419764e+11, 2.170000e+09, -4.240780e+10,
-3.289060e+10, -8.960120e+10, -1.504524e+11, -5.954640e+10,
-2.516560e+10, -2.704862e+11, -1.354968e+11, -1.476200e+09,
-1.787320e+10, 1.125460e+10, -1.828580e+10, 2.956740e+10,
-6.059700e+10, 2.598300e+10, -2.275540e+10, -3.208720e+10,
-5.410800e+10, -6.257460e+10, 1.038940e+10, -1.236730e+11,
-2.074720e+11, -6.420140e+10, 2.437620e+10, -2.717840e+11,
-1.472140e+10, -4.442600e+09, -3.295240e+10, -1.885412e+11,
-2.746886e+11, -6.276000e+10, 7.486000e+08, -5.355180e+10,
2.882580e+10, -4.874000e+08, -3.091300e+10, -3.020242e+11,
2.894940e+10, 2.721900e+10, -5.620920e+10, -5.874300e+10,
-3.453800e+09, -2.522740e+10, -6.110000e+08, -2.925070e+11,
-2.689600e+10, -1.785320e+10, -1.882322e+11, -2.496020e+10,
5.074600e+09, -2.837920e+10, -1.489692e+11, -5.367540e+10,
-3.134560e+10, -1.871816e+11, -4.922580e+10, 3.591400e+09,
-1.371260e+10, -1.540368e+11, -1.181680e+10, 4.396000e+08,
-2.988106e+11, -3.900880e+10, 6.250000e+08, 2.425260e+10,
-2.106856e+11, -5.925800e+09, -2.747504e+11, 5.014000e+08,
-1.397980e+10, -3.350200e+09, -1.663720e+10, -1.166000e+08,
-8.582000e+08, 2.969100e+10, -2.401224e+11, -2.485660e+10,
-8.842700e+10, -2.887360e+10, 2.165700e+10, 2.406720e+10,
-4.389100e+10, -7.346000e+08, -2.899720e+10, 2.886760e+10,
-5.905200e+10, -7.409000e+09, -2.669060e+10, -6.053520e+10,
-1.779140e+10, -2.368240e+10, -6.728000e+08, -2.638160e+10,
-1.487220e+11, -1.373260e+10, 6.557800e+09, 2.610660e+10,
-2.099440e+11, -1.021000e+10, -9.176420e+10, -1.167200e+09,
2.666280e+10, -2.720500e+10, -6.022620e+10, -6.358400e+09,
-2.850280e+10, -5.324280e+10, -9.200000e+08, 2.548860e+10,
-6.109140e+10, -2.232280e+10, 2.870220e+10, -3.048040e+10,
-1.265976e+11, -2.147644e+11, -8.663480e+10, 2.744620e+10,
-2.380600e+10, -1.893446e+11, -1.500816e+11, -4.531240e+10,
-1.483512e+11, -3.086368e+11, -5.555000e+09, 1.700200e+10,
-7.759200e+10, -5.361360e+10, -4.129540e+10, -2.999230e+11,
-2.263180e+10, -1.352600e+09, 2.585940e+10, 9.340000e+08,
-6.220380e+10, -1.550480e+10, -5.787780e+10, -2.817380e+10,
-5.219220e+10, 2.283120e+10, -4.628000e+09, -6.028800e+10,
-3.577400e+09, -3.041860e+10, -3.220674e+11, -3.387940e+10,
-3.085120e+10, -2.016628e+11, -4.333480e+10, -3.020000e+08,
-1.216336e+11, -2.708140e+10, -2.873000e+10, -6.455220e+10,
-1.933640e+10, -8.912200e+09, -2.498020e+10, -5.616800e+09,
-5.515860e+10, -1.599800e+09, -6.634440e+10, -2.664880e+10,
-1.572504e+11, -5.738340e+10, -6.245100e+10, -5.967000e+10,
-4.434360e+10, -1.686440e+10, 2.962920e+10, -2.703008e+11,
-2.423860e+10, -6.795120e+10, -6.482000e+09, -2.105620e+11,
2.163700e+10, -2.825560e+10, -1.349406e+11, -1.810016e+11,
-2.406786e+11, -2.528920e+10, -3.439380e+10, -8.885960e+10,
-5.534400e+10, -3.054220e+10, -6.201840e+10, -2.989960e+11,
-2.806832e+11, 2.808420e+10, -2.411500e+10, -1.771082e+11,
-3.276700e+10, 3.653200e+09, -5.942280e+10, -2.794660e+10,
-5.948460e+10, -3.007264e+11, -6.720960e+10, -4.471440e+10,
-5.250120e+10, -1.510704e+11, 1.415920e+10, -1.488680e+10,
-3.078940e+10, -1.490680e+10, 1.848520e+10, 2.449980e+10,
-2.217800e+09, -2.940320e+11, -3.350860e+10, 1.996840e+10,
2.108200e+09, 5.632000e+08, -1.908920e+10, -2.378976e+11,
-1.784000e+08, -2.392960e+10, -1.692620e+10, -4.768080e+10,
-2.633980e+10, 8.041000e+09, -3.585700e+10, -2.646340e+10,
-2.726680e+10, -2.650400e+09, -3.876154e+11, -2.217920e+10,
-7.100000e+09, -2.145760e+10, -3.313780e+10, -1.799510e+11,
1.658940e+10, 2.138980e+10, -8.811800e+10, -9.818000e+08,
-6.671520e+10, -8.162900e+10, -2.071600e+10, -8.830340e+10,
-4.601220e+10, -1.105520e+10, -2.343520e+10, -1.194706e+11,
1.675600e+09, -3.171640e+10, -6.072060e+10, -2.671060e+10,
-1.624640e+10, -2.374420e+10, 2.400540e+10, -6.791000e+09,
-5.184200e+09, -6.208020e+10, -2.751400e+10, -2.510380e+10,
-2.975128e+11, -2.831740e+10, -2.664074e+11, -7.347200e+09,
-3.036928e+11, -4.174800e+10, -3.161280e+10, -2.462406e+11,
9.729600e+09, -2.417680e+10, -3.600326e+11, 8.104000e+08,
1.990660e+10, 1.516800e+10, -2.371560e+11, -2.650478e+11,
-1.495254e+11, -2.156000e+09, -2.541280e+10, 5.383600e+09,
-2.584540e+10, -1.489074e+11, -1.505142e+11, -2.413584e+11,
-2.423472e+11, -3.118020e+10, -3.392000e+09, -5.070900e+10,
-6.374880e+10, -2.386780e+10, -7.985200e+09, -4.821700e+10,
-3.638000e+08, -2.448580e+10, -2.588600e+09, -5.243940e+10,
-2.372420e+10, -3.826720e+10, 2.517960e+10, -4.277860e+10,
-3.214900e+10, -5.052360e+10, -2.960296e+11, 2.215140e+10,
-2.590720e+10, 3.778000e+08, 2.363460e+10, -7.779800e+09,
-3.288036e+11, -7.717940e+10, 1.924680e+10, -1.599920e+10,
-1.866254e+11, -8.088800e+09, -3.767386e+11, -2.404932e+11,
-1.202122e+11, -1.414400e+09, -3.258160e+10, 2.431440e+10,
-1.970600e+09, -3.116020e+10, -5.936100e+10, -8.929220e+10,
1.984480e+10, -8.848880e+10, -9.324800e+09, 1.106920e+10,
-3.122200e+10, -2.434220e+10, -7.322420e+10, -2.685086e+11,
-5.342820e+10, -1.334180e+10, -1.818668e+11, -7.915700e+10,
-3.560980e+10, -1.970720e+10, -5.347000e+10, 1.924000e+08,
-3.678400e+10, -2.468586e+11, -2.306440e+10, 2.435620e+10,
2.697180e+10, -1.457780e+10, -2.512464e+11, -7.606700e+10,
-2.701772e+11, -1.185860e+10, -4.504400e+09, -1.502670e+11,
-5.658000e+10, -8.027000e+09, -1.019000e+10, -4.774260e+10,
-1.917100e+10, -1.785200e+09, -3.239832e+11, -7.038200e+09,
-5.018800e+09, 3.796800e+09, -3.734020e+10, -2.935576e+11,
-5.503500e+10, -1.200886e+11, -2.432742e+11, -2.477238e+11,
-3.165672e+11, -2.990578e+11, 1.613800e+09, -1.616382e+11,
2.876400e+10, -2.403078e+11, -1.230750e+11, -7.903400e+09,
1.628040e+10, -3.313992e+11, -2.090788e+11, -2.596900e+10,
-4.904040e+10, 2.005020e+10, -8.508980e+10, 5.136400e+09,
-2.151940e+10, -2.700536e+11, -2.424090e+11, -9.170240e+10,
-2.949160e+10, -4.014120e+10, -2.576360e+10, -7.314240e+10,
-2.844100e+10, -2.355880e+10, -3.639200e+09, -5.664180e+10,
-1.179680e+10, -1.923280e+10, -6.702420e+10, 1.984600e+09,
-3.209550e+11, -2.226100e+10, 1.558060e+10, -1.043600e+09,
-6.502000e+09, -1.557672e+11, -2.201380e+10, -8.333940e+10,
-6.146220e+10, 1.325220e+10, -4.380800e+09, -1.251144e+11,
-1.908800e+09, -4.679560e+10, -1.342360e+10, -2.053060e+10,
-2.415438e+11, -3.591056e+11, -6.041160e+10, -1.853894e+11,
-2.924452e+11, -5.107980e+10, -1.490310e+11, -3.308430e+11,
-6.735320e+10, -5.246000e+09, -2.924440e+10, 6.681400e+09,
-4.277200e+09, -2.386392e+11, -4.875200e+09, -8.954000e+09,
2.252220e+10, -3.035680e+10, -3.047016e+11, -2.854460e+10,
-2.582540e+10, -3.824600e+09, -1.389800e+10, -4.133600e+09,
-2.690030e+11, 1.473540e+10, -1.552110e+11, -3.437380e+10,
6.496000e+09, -2.219920e+10, -2.553640e+10, -1.835354e+11,
-2.279720e+10, -4.607400e+10, -3.591880e+10, -2.709606e+11,
-2.497632e+11, -2.654804e+11, -1.476320e+10, 2.901120e+10,
-1.192234e+11, -1.630820e+10, 2.103900e+10, -1.189144e+11,
-1.540120e+10, -1.834760e+10, -5.793960e+10, -8.694380e+10,
3.097000e+09, -3.981220e+10, -8.014580e+10, -1.105400e+09,
-1.192852e+11, -1.789622e+11, -2.572180e+10, -2.819380e+10,
-6.420200e+09, -1.500198e+11, -3.066580e+10, -2.615440e+10,
-9.343280e+10, 3.406000e+09, -3.306576e+11, -5.917560e+10,
8.722000e+08, -3.536260e+10, -8.484260e+10, -2.056798e+11,
-2.749358e+11, 2.728080e+10, -1.790858e+11, -2.077780e+10,
-2.103148e+11, -1.194040e+10, 2.864040e+10, -1.268200e+10,
2.287300e+10, -2.734526e+11, 1.842340e+10, 2.789880e+10,
-1.983080e+10, -6.127680e+10, -1.847120e+10, -8.515160e+10,
-3.597400e+09, -9.633800e+09, -1.317640e+10, -1.578066e+11,
-1.195324e+11, -2.428040e+10, -4.051200e+10, -2.421618e+11,
-3.406480e+10, 8.226400e+09, -3.319960e+10, -5.892840e+10,
-2.331160e+10, -2.856460e+10, -2.714320e+10, -4.625940e+10,
-3.004780e+10, -3.307600e+10, -2.438304e+11, -1.698800e+10,
2.073000e+10, -2.520740e+10, -1.482500e+10, -2.269360e+10,
-2.709188e+11, -2.373414e+11, -2.417292e+11, -3.135390e+11,
-2.910656e+11, -3.233440e+10, 1.273780e+10, -2.627800e+10,
1.187260e+10, -1.652844e+11, 1.860880e+10, -5.818680e+10,
-9.065180e+10, -3.202540e+10, -1.680036e+11, -5.740400e+09,
-2.707952e+11, 9.833200e+09, 2.715720e+10, -2.150734e+11,
-2.905900e+10, 1.275780e+10, -1.799680e+10, -2.724680e+10,
-9.194960e+10, 2.046400e+09, -2.821664e+11, -2.362060e+10,
-2.267360e+10, -6.140040e+10, 1.541520e+10, -4.426180e+10,
-1.395980e+10, -3.610420e+10, 6.619600e+09, -3.005410e+11,
-1.402160e+10, -2.930620e+10, -2.557820e+10, 1.776360e+10,
-2.730860e+10, -3.927600e+10, -1.027180e+10, -5.987600e+09,
-7.841600e+09, -3.091930e+11, -1.340360e+10, -1.111700e+10,
-3.754560e+10, -2.116744e+11, -2.732672e+11, -5.213040e+10,
-2.735144e+11, 2.616840e+10, -2.707334e+11, -8.055840e+10,
-1.249660e+10, 1.306000e+08, -4.071800e+09, -1.865018e+11,
3.160000e+08, -1.869962e+11, 2.128620e+10, -6.234800e+09,
1.718740e+10, -3.272520e+10, -5.060600e+09, -9.040460e+10,
-1.927460e+10, -1.995440e+10, -1.808162e+11, -8.644940e+10,
-2.761718e+11, -2.430040e+10, 2.394360e+10, -1.503040e+10,
-3.142740e+10, -2.143760e+10, 1.232520e+10, -2.763760e+10,
-1.626640e+10, -6.065880e+10, -8.665000e+09, -2.680760e+11,
-2.794000e+09, -2.800840e+10, 9.215200e+09, 2.066820e+10,
-1.503906e+11, -6.605600e+09, -2.954116e+11, -5.923740e+10,
-1.184818e+11, -4.755720e+10, -1.231168e+11, 2.417200e+09,
-4.180980e+10, -1.229000e+09, -2.285900e+10, -2.880992e+11,
-2.337340e+10, -1.571020e+10, -2.955340e+10, -1.221898e+11,
-1.063490e+11, -1.456938e+11, 6.372400e+09, -5.497320e+10,
-1.538000e+09, 9.524200e+09, -6.486120e+10, -2.003620e+10,
-2.131576e+11, -2.980060e+10, -1.827320e+11, -2.669636e+11,
-4.329300e+10, -2.897600e+09, -2.141464e+11, -2.999848e+11,
-3.065974e+11, -1.637000e+10, -5.855760e+10, -5.781600e+10,
-4.195400e+09, -2.059240e+10, -1.774960e+10, -2.255794e+11,
-2.719076e+11, 1.255240e+10, -9.567760e+10, -2.454760e+10,
-2.212534e+11, -1.416520e+10, -1.784678e+11, -1.948000e+10,
-2.409500e+10, 6.868000e+08, -2.076992e+11, -2.114860e+10,
-8.607860e+10, -2.117980e+11, -7.944600e+10, -3.021200e+09,
-2.918260e+10, -2.769940e+10, -1.249708e+11, 2.276940e+10,
-5.126520e+10, -7.174100e+10, -1.549020e+11, -1.639000e+10,
5.260000e+09, -2.722166e+11, -1.037540e+10, 2.975280e+10,
-4.574500e+10, 1.131640e+10, -2.069600e+10, 6.701400e+09,
-1.235300e+10, -2.782300e+10, -6.102960e+10, -3.190180e+10,
-3.944140e+10, -7.305400e+09, -4.477620e+10, -6.034980e+10,
-1.253840e+10, 1.799200e+09, -1.523682e+11, -1.194088e+11])
#region III Ramp+Storage single area : loading parameters
Zones="FR"
year=2013
Selected_TECHNOLOGIES=['OldNuke','WindOnShore', 'CCG',"curtailment",'HydroRiver', 'HydroReservoir',"Solar"] ## try adding 'HydroRiver', 'HydroReservoir'
#### reading CSV files
areaConsumption = pd.read_csv(InputConsumptionFolder+'areaConsumption'+str(year)+'_'+str(Zones)+'.csv',
sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date"])
availabilityFactor = pd.read_csv(InputProductionFolder+'availabilityFactor'+str(year)+'_'+str(Zones)+'.csv',
sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date","TECHNOLOGIES"])
TechParameters = pd.read_csv(InputPlaningFolder+'Planing-RAMP1BIS_TECHNOLOGIES.csv',
sep=',',decimal='.',skiprows=0,comment="#").set_index(["TECHNOLOGIES"])
StorageParameters = pd.read_csv(InputPlaningFolder+'Planing-RAMP1_STOCK_TECHNO.csv',sep=',',decimal='.',skiprows=0).set_index(["STOCK_TECHNO"])
#### Selection of subset
availabilityFactor=availabilityFactor.loc[(slice(None),Selected_TECHNOLOGIES),:]
TechParameters=TechParameters.loc[Selected_TECHNOLOGIES,:]
#TechParameters.loc["CCG",'capacity']=100000 ## margin to make everything work
TechParameters.loc["CCG",'maxCapacity']=70000
TechParameters.loc["OldNuke",'maxCapacity']=35000
TechParameters.loc["OldNuke",'RampConstraintMoins']=0.03 ## a bit strong to put in light the effect
TechParameters.loc["OldNuke",'RampConstraintPlus']=0.03 ## a bit strong to put in light the effect
#endregion
/var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/2552567369.py:17: FutureWarning: The behavior of indexing on a MultiIndex with a nested sequence of labels is deprecated and will change in a future version. `series.loc[label, sequence]` will raise if any members of 'sequence' or not present in the index's second level. To retain the old behavior, use `series.index.isin(sequence, level=1)`
#region III Ramp+Storage single area : solving and loading results
model = GetElectricSystemModel_PlaningSingleNode_withStorage(Parameters={"areaConsumption" : areaConsumption,
"availabilityFactor" : availabilityFactor,
"TechParameters" : TechParameters,
"StorageParameters": StorageParameters})
if solver in solverpath : opt = SolverFactory(solver,executable=solverpath[solver])
else : opt = SolverFactory(solver)
results=opt.solve(model)
Variables = getVariables_panda_indexed(model)
Constraints = getConstraintsDual_panda(model)
production_df=Variables['energy'].pivot(index="Date",columns='TECHNOLOGIES', values='energy')
production_df.loc[:,'Storage'] = Variables['storageOut'].pivot(index='Date',columns='STOCK_TECHNO',values='storageOut').sum(axis=1)-Variables['storageIn'].pivot(index='Date',columns='STOCK_TECHNO',values='storageIn').sum(axis=1) ### put storage in the production time series
production_df.sum(axis=0)/10**6 ### energies produites TWh
production_df[production_df>0].sum(axis=0)/10**6 ### energies produites TWh
production_df.max(axis=0)/1000 ### Pmax en GW
fig=MyStackedPlotly(y_df=production_df, Conso=areaConsumption)
fig=fig.update_layout(title_text="Production électrique (en KWh)", xaxis_title="heures de l'année")
#plotly.offline.plot(fig, filename='file.html') ## offline
fig.show()
#endregion
WARNING: Implicitly replacing the Component attribute stockLevel_ini
(type=<class 'pyomo.core.base.param.IndexedParam'>) on block unknown with
a new Component (type=<class 'pyomo.core.base.var.IndexedVar'>). This is
usually indicative of a modelling error. To avoid this warning, use
block.del_component() and block.add_component().
This case is a one node case, not realistic to analyse the future of the electric system, but usefull to learn to use the tool. If you want to use a more complete case, you can use the 7 node EU model
This simple system has no interconnection, no flexible demand. Flexibility is mainly done with storage and gaz.
#region IV Case Storage + CCG + PV + Wind + hydro (Ramp+Storage single area) : loading parameters
Zones="FR"
year=2013
Selected_TECHNOLOGIES=['CCG', 'WindOnShore','WindOffShore','Solar',"curtailment",'HydroRiver', 'HydroReservoir']
#### reading CSV files
areaConsumption = pd.read_csv(InputConsumptionFolder+'areaConsumption'+str(year)+'_'+str(Zones)+'.csv',
sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date"])
availabilityFactor = pd.read_csv(InputProductionFolder+'availabilityFactor'+str(year)+'_'+str(Zones)+'.csv',
sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date","TECHNOLOGIES"])
TechParameters = pd.read_csv(InputPlaningFolder+'Planing-RAMP1BIS_TECHNOLOGIES.csv',
sep=',',decimal='.',skiprows=0,comment="#").set_index(["TECHNOLOGIES"])
StorageParameters = pd.read_csv(InputPlaningFolder+'Planing-RAMP1_STOCK_TECHNO.csv',
sep=',',decimal='.',skiprows=0).set_index(["STOCK_TECHNO"])
#### Selection of subset
availabilityFactor=availabilityFactor.loc[(slice(None),Selected_TECHNOLOGIES),:]
TechParameters=TechParameters.loc[Selected_TECHNOLOGIES,:]
#TechParameters.loc["CCG",'capacity']=100000 ## margin to make everything work
TechParameters.loc["CCG",'energyCost']=100
TechParameters.loc["CCG",'maxCapacity']=50000
TechParameters.loc["WindOnShore",'capacityCost']=120000 #€/MW/year - investment+O&M fixed cost
TechParameters.loc["Solar",'capacityCost']=65000 #€/MW/year
TechParameters.loc["CCG",'RampConstraintMoins']=0.4 ## a bit strong to put in light the effect
TechParameters.loc["CCG",'RampConstraintPlus']=0.4 ## a bit strong to put in light the effect
StorageParameters.loc["Battery1","p_max"]=10000 # this is not optimized - batteries
StorageParameters.loc["Battery2","p_max"]=7000 # this is not optimized - Pumped HS
StorageParameters.loc["Battery2","c_max"]=StorageParameters.loc["Battery2","p_max"]*20 # this is not optimized 20h of Pumped HS
#endregion
/var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/2233090117.py:17: FutureWarning: The behavior of indexing on a MultiIndex with a nested sequence of labels is deprecated and will change in a future version. `series.loc[label, sequence]` will raise if any members of 'sequence' or not present in the index's second level. To retain the old behavior, use `series.index.isin(sequence, level=1)`
#region IV Case Storage + CCG + PV + Wind + hydro (Ramp+Storage single area) : solving and loading results
model = GetElectricSystemModel_PlaningSingleNode_withStorage(Parameters={"areaConsumption" : areaConsumption,
"availabilityFactor" : availabilityFactor,
"TechParameters" : TechParameters,
"StorageParameters" : StorageParameters})
if solver in solverpath : opt = SolverFactory(solver,executable=solverpath[solver])
else : opt = SolverFactory(solver)
results=opt.solve(model)
Variables = getVariables_panda_indexed(model)
Constraints = getConstraintsDual_panda(model)
production_df=Variables['energy'].pivot(index="Date",columns='TECHNOLOGIES', values='energy')
production_df.loc[:,'Storage'] = Variables['storageOut'].pivot(index='Date',columns='STOCK_TECHNO',values='storageOut').sum(axis=1)-Variables['storageIn'].pivot(index='Date',columns='STOCK_TECHNO',values='storageIn').sum(axis=1) ### put storage in the production time series
production_df.sum(axis=0)/10**6 ### energies produites TWh
production_df[production_df>0].sum(axis=0)/10**6 ### energies produites TWh
production_df.max(axis=0)/1000 ### Pmax en GW
fig=MyStackedPlotly(y_df=production_df, Conso=areaConsumption)
fig=fig.update_layout(title_text="Production électrique (en KWh)", xaxis_title="heures de l'année")
#plotly.offline.plot(fig, filename='file.html') ## offline
fig.show()
#endregion
WARNING: Implicitly replacing the Component attribute stockLevel_ini
(type=<class 'pyomo.core.base.param.IndexedParam'>) on block unknown with
a new Component (type=<class 'pyomo.core.base.var.IndexedVar'>). This is
usually indicative of a modelling error. To avoid this warning, use
block.del_component() and block.add_component().
This case is a one node case, not realistic to analyse the future of the electric system, but usefull to learn to use the tool. If you want to use a more complete case, you can use the 7 node EU model
#region V - Simple single area +4 million EV + demande side management +30TWh H2: loading parameters
Zones="FR" ; year=2013
#### reading areaConsumption availabilityFactor and TechParameters CSV files
#areaConsumption = pd.read_csv(InputConsumptionFolder+'areaConsumption'+str(year)+'_'+str(Zones)+'.csv',sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date"])
TemperatureThreshold = 15
ConsoTempe_df=pd.read_csv(InputConsumptionFolder+'ConsumptionTemperature_1996TO2019_FR.csv',parse_dates=['Date']).\
set_index(["Date"])[str(year)]
ConsoTempe_df=ConsoTempe_df[~ConsoTempe_df.index.duplicated(keep='first')]
(ConsoTempeYear_decomposed_df,Thermosensibilite)=Decomposeconso(ConsoTempe_df,TemperatureThreshold=TemperatureThreshold)
#obtaining industry-metal consumption
# & x["type"] == "Ind" & x["UsageDetail"] == "Process").\
Profile_df_sans_chauffage=pd.read_csv(InputConsumptionFolder+"ConsumptionDetailedProfiles.csv").\
rename(columns={'heures':'Heure',"WeekDay":"Jour"}).\
replace({"Jour" :{"Sat": "Samedi" , "Week":"Semaine" , "Sun": "Dimanche"}}). \
query('UsagesGroupe != "Chauffage"'). \
assign(is_steel=lambda x: x["Nature"].isin(["MineraiMetal"])).\
set_index(["Mois", "Heure",'Nature', 'type',"is_steel", 'UsagesGroupe', 'UsageDetail', "Jour"]).\
groupby(["Mois","Jour","Heure","type","is_steel"]).sum().\
merge(add_day_month_hour(df=ConsoTempeYear_decomposed_df,semaine_simplifie=True,French=True,to_index=True),
how="outer",left_index=True,right_index=True).reset_index().set_index("Date")[["type","is_steel","Conso"]]. \
pivot_table(index="Date", columns=["type","is_steel"], values='Conso')
Profile_df_sans_chauffage.columns = ["Autre","Ind_sans_acier","Ind_acier","Residentiel","Tertiaire"]
Profile_df_sans_chauffage=Profile_df_sans_chauffage.loc[:,Profile_df_sans_chauffage.sum(axis=0)>0]
Profile_df_n=Profile_df_sans_chauffage.div(Profile_df_sans_chauffage.sum(axis=1), axis=0) ### normalisation par 1 et multiplication
for col in Profile_df_sans_chauffage.columns:
Profile_df_sans_chauffage[col]=Profile_df_n[col]*ConsoTempeYear_decomposed_df["NTS_C"]
steel_consumption=Profile_df_sans_chauffage.loc[:,"Ind_acier"]
steel_consumption.max()
steel_consumption[steel_consumption.isna()]=110
steel_consumption.isna().sum()
# if you want to change thermal sensitivity + add electric vehicle
VEProfile_df=pd.read_csv(InputConsumptionFolder+'EVModel.csv', sep=';')
NbVE=10 # millions
ev_consumption = NbVE*Profile2Consumption(Profile_df=VEProfile_df,Temperature_df = ConsoTempe_df.loc[str(year)][['Temperature']])[['Consumption']]
h2_Energy = 30000## H2 volume in GWh/year
h2_Energy_flat_consumption = ev_consumption.Consumption*0+h2_Energy/8760
to_flexible_consumption=pd.DataFrame({'to_flex_consumption': steel_consumption,'FLEX_CONSUM' : 'Steel'}).reset_index().set_index(['Date','FLEX_CONSUM']).\
append(pd.DataFrame({'to_flex_consumption': ev_consumption.Consumption,'FLEX_CONSUM' : 'EV'}).reset_index().set_index(['Date','FLEX_CONSUM'])).\
append(pd.DataFrame({'to_flex_consumption': h2_Energy_flat_consumption,'FLEX_CONSUM' : 'H2'}).reset_index().set_index(['Date','FLEX_CONSUM']))
availabilityFactor = pd.read_csv(InputProductionFolder+'availabilityFactor'+str(year)+'_'+str(Zones)+'.csv',sep=',',decimal='.',skiprows=0,parse_dates=['Date']).set_index(["Date","TECHNOLOGIES"])
TechParameters = pd.read_csv(InputPlaningFolder+'Planing-RAMP1BIS_TECHNOLOGIES.csv',sep=',',decimal='.',skiprows=0,comment="#").set_index(["TECHNOLOGIES"])
StorageParameters = pd.read_csv(InputPlaningFolder + 'Planing-RAMP1_STOCK_TECHNO.csv', sep=',', decimal='.',
skiprows=0).set_index(["STOCK_TECHNO"])
ConsoParameters = pd.read_csv(InputPlaningFolder + "Planing-Conso-FLEX_CONSUM.csv", sep=";").set_index(["FLEX_CONSUM"])
ConsoParameters_ = ConsoParameters.join(
to_flexible_consumption.groupby("FLEX_CONSUM").max().rename(columns={"to_flexible_consumption": "max_power"}))
Selected_TECHNOLOGIES=['OldNuke','CCG','TAC', 'WindOnShore', 'WindOffShore','HydroReservoir','HydroRiver','Solar','curtailment']#you can add technologies here
availabilityFactor=availabilityFactor.loc[(slice(None),Selected_TECHNOLOGIES),:]
TechParameters=TechParameters.loc[Selected_TECHNOLOGIES,:]
TechParameters.loc["CCG",'energyCost']=100
TechParameters.loc["CCG",'maxCapacity']=50000
TechParameters.loc["WindOnShore",'capacityCost']=120000 #€/MW/year - investment+O&M fixed cost
TechParameters.loc["Solar",'capacityCost']=65000 #€/MW/year
TechParameters.loc["CCG",'RampConstraintMoins']=0.4 ## a bit strong to put in light the effect
TechParameters.loc["CCG",'RampConstraintPlus']=0.4 ## a bit strong to put in light the effect
StorageParameters.loc["Battery1","p_max"]=10000 # this is not optimized - batteries
StorageParameters.loc["Battery2","p_max"]=7000 # this is not optimized - Pumped HS
StorageParameters.loc["Battery2","c_max"]=StorageParameters.loc["Battery2","p_max"]*20 # this is not optimized 20h of Pumped HS
areaConsumption=pd.DataFrame(ConsoTempeYear_decomposed_df.loc[:,"Consumption"]-steel_consumption,columns=["areaConsumption"])
def labour_ratio_cost(df): # higher labour costs at night
if df.hour in range(7, 17):
return 1
elif df.hour in range(17, 23):
return 1.5
else:
return 2
labour_ratio = pd.DataFrame()
labour_ratio["Date"] = areaConsumption.index.get_level_values('Date')
labour_ratio["FLEX_CONSUM"] = "Steel"
labour_ratio["labour_ratio"] = labour_ratio["Date"].apply(labour_ratio_cost)
labour_ratio.set_index(["Date","FLEX_CONSUM"], inplace=True)
#model.labour_ratio = Param(model.Date, initialize=labour_ratio.squeeze().to_dict())
# endregion
/var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/812183875.py:7: FutureWarning: Indexing a DataFrame with a datetimelike index using a single string to slice the rows, like `frame[string]`, is deprecated and will be removed in a future version. Use `frame.loc[string]` instead. /var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/812183875.py:45: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. /var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/812183875.py:46: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. /var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/ipykernel_35080/812183875.py:60: FutureWarning: The behavior of indexing on a MultiIndex with a nested sequence of labels is deprecated and will change in a future version. `series.loc[label, sequence]` will raise if any members of 'sequence' or not present in the index's second level. To retain the old behavior, use `series.index.isin(sequence, level=1)`
#region V - Simple single area +4 million EV + demande side management +30TWh H2: solving and loading results
# €/kW/an coût fixe additionnel pour un GW d'électrolyseur en plus en supposant que l'on construit
model = Model_SingleNode_online_flex(Parameters={"areaConsumption" : areaConsumption,
"availabilityFactor" : availabilityFactor,
"TechParameters" : TechParameters,
"StorageParameters" : StorageParameters,
"to_flexible_consumption" : to_flexible_consumption,
"ConsoParameters" : ConsoParameters_,
"labour_ratio": labour_ratio})
if solver in solverpath : opt = SolverFactory(solver,executable=solverpath[solver])
else : opt = SolverFactory(solver)
results=opt.solve(model)
Variables = getVariables_panda_indexed(model)
Variables.keys()
Variables['increased_max_power'] ## on a ajouté X GW à ce qui existait.
print(extractCosts(Variables))
print(extractEnergyCapacity(Variables))
Constraints = getConstraintsDual_panda(model)
production_df=Variables['energy'].pivot(index="Date",columns='TECHNOLOGIES', values='energy')
production_df.loc[:,'Storage'] = Variables['storageOut'].pivot(index='Date',columns='STOCK_TECHNO',values='storageOut').sum(axis=1)-Variables['storageIn'].pivot(index='Date',columns='STOCK_TECHNO',values='storageIn').sum(axis=1) ### put storage in the production time series
production_df.sum(axis=0)/10**6 ### energies produites TWh
production_df[production_df>0].sum(axis=0)/10**6 ### energies produites TWh
production_df.max(axis=0)/1000 ### Pmax en GW
fig=MyStackedPlotly(y_df=production_df, Conso=areaConsumption)
fig=fig.update_layout(title_text="Production électrique (en KWh)", xaxis_title="heures de l'année")
#plotly.offline.plot(fig, filename='file.html') ## offline
fig.show()
#endregion
/Users/robin.girard/Documents/Code/Etude/Energy-Alternatives-Planing/Models/Basic_France_models/Planing_optimisation/../../../Models/Basic_France_models/Planing_optimisation/f_planingModels.py:362: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
Capacity_Milliards_euros Energy_Milliards_euros
TECHNOLOGIES
TAC 2.556545 4.499245
HydroRiver 0.807500 0.000000
curtailment 0.000000 -0.000000
CCG 0.000000 -0.000000
HydroReservoir 0.565250 0.000000
WindOffShore 4.728668 0.000000
Solar 2.246639 0.000000
OldNuke 9.802400 1.772419
WindOnShore 1.609200 0.000000
Capacity_GW Production_TWh
TECHNOLOGIES
TAC 25.514422 53.562441
HydroRiver 10.000000 48.773636
curtailment 1000.000000 0.000000
CCG 0.000000 0.000000
HydroReservoir 7.000000 14.700000
WindOffShore 22.423501 80.520562
Solar 34.563681 40.784792
OldNuke 40.000000 253.202748
WindOnShore 13.410000 27.350294